package com.taotao.manage.controller;

import com.taotao.manage.pojo.ItemDesc;
import com.taotao.manage.service.ItemDescService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * java类简单作用描述
 *
 * @ProjectName: taotao
 * @Package: com.taotao.manage.controller
 * @ClassName: ${TYPE_NAME}
 * @Description: java类作用描述
 * @Author: 作者姓名
 * @CreateDate: 2018/4/23 1:32
 * @UpdateUser: Neil.Zhou
 * @UpdateDate: 2018/4/23 1:32
 * @UpdateRemark: The modified content
 * @Version: 1.0
 * <p>
 * Copyright: Copyright (c) 2018
 */
@Controller
@RequestMapping(value = "/item/desc")
public class ItemDescController {

    @Autowired
    private ItemDescService itemDescService;

    @RequestMapping(value = "{itemId}",method = RequestMethod.GET)
    public ResponseEntity<ItemDesc> queryItemDescById(@PathVariable("itemId")Long itemId){
        try {
            if (itemId==null||itemId.longValue()<0){
                return ResponseEntity.badRequest().build();
            }
            ItemDesc itemDesc = itemDescService.queryById(itemId);
            if (itemDesc==null){
                return ResponseEntity.notFound().build();
            }
            return ResponseEntity.ok(itemDesc);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
